package com.spring.demo6.eg1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author vhans
 */
@Component
public class Service3 {

    private Service1 service1;

    // 在方法上加@Autowired注解进行注入
    @Autowired
    public void injectService1(Service1 service1) {
        this.service1 = service1;
    }

    @Override
    public String toString() {
        return "Service3{" +
                "service1=" + service1 +
                '}';
    }
}
